package com.zhaoyd.uaademo.controller;

import com.zhaoyd.uaademo.core.ResultData;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    //administrator角色允许访问
    @PreAuthorize("hasRole('administrator')")
    @RequestMapping("hello")
    public String hello(){
        return "hello world";
    }
    //add权限允许访问
    @PreAuthorize("hasAnyAuthority('add')")
    @RequestMapping("hello1")
    public ResultData hello1(){
        return ResultData.success();
    }

    @PreAuthorize("hasAnyAuthority('del')")
    @RequestMapping("hello2")
    public ResultData hello2(){
        return ResultData.success("hello2 你好");
    }
}
